<?php
/**
*+-------腾讯微博用户接入控制器--------+
*+-------------------------------------------------+
*-------对于腾讯微博用户接入的控制处理
*+-------------------------------------------------+
*+-@author susy.liang <liangling@ilongyuan.com.cn>-+
*+-------------------------------------------------+
*/
namespace Auth\Event;

class TencentEvent extends PublicEvent {	

	/**
	*回调
	*/
	 public function callBack($param=array()){
	 	if($_GET['state'] && $_GET['code']){//code的回调
   			$state = session('state');
   			if($state != $_GET['state']){
   				echo 'param:state illegal';
   				exit();
   			}
   			
   			$this->getToken($_GET['code'], U('Auth/callBack', array('channel'=>'tencent')));

   		}elseif($_GET['access_token']){//token的回调
   			$token = $_GET['access_token'];
   			$openid = $this->getOpenid($token);
   			if(!$openid){
   				echo 'get openid failed';
   				exit();
   			}
   			$user = $this->getUser($openid, $token);
            //TODO:add user
   			exit();
   		}
	}

	public function getToken(){

	}

	public function getOpenid(){

	}

	public function getUser(){

	}
}